@extends('admin.layout.layout', ['row' => @$page])
@section('style')
    <style>
        .table .tth{
            background-color: rgba(0, 0, 0, 0.05);
            width: 150px;
            font-weight: bold;
        }
        .table .ttd{
            width: 350px;
        }
        .table .ttt{
            padding: 0;
        }
        .ttt .table{
            margin: 0;
        }
        .ttt .table img + p{
            text-align: center;
            margin: 10px 0 0;
        }
        .tst{
            color: #1e89e0;
            font-weight: 700;
            text-align: center;
            font-size: 1.25rem;
        }
    </style>
@endsection
@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions">
                {{--<div class="item">
                    <a href="/{{ request()->path() }}/create" class="btn btn-sm btn-primary">{{ ts('addnew') }}</a>
                </div>--}}
            </div>
        </div>

        <div>
            <table class="table s3">
                <tbody>
                <tr>
                    <td colspan="6" class="tst">{{ ts('baseinformation') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('zh') }}</td>
                    <td class="ttd">{{ $data->unique_id }}</td>
                    <td class="tth">{{ ts('jc') }}</td>
                    <td class="ttd">{{ $data->abbr }}</td>
                    <td class="tth">{{ ts('companyname') }}</td>
                    <td class="ttd">{{ $data->company_name }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('phonenumber') }}</td>
                    <td class="ttd">{{ $data->extension }} {{ $data->phone_number }}</td>
                    <td class="tth">{{ ts('email') }}</td>
                    <td class="ttd">{{ $data->email_address }}</td>
                    <td class="tth">{{ ts('status') }}</td>
                    <td class="ttd">{{ $data->status == 1 ? ts('active') : ts('DEACTIVE') }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('regionInformation') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('region') }}</td>
                    <td>{{ ts('region_master.'.$data->region_id) }}</td>
                    <td class="tth">{{ ts('province') }}</td>
                    <td>{{ ts('province_master.'.$data->province_id) }}</td>
                    <td class="tth">{{ ts('city') }}</td>
                    <td>{{ ts('cities.'.$data->city) }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('addresss') }}</td>
                    <td colspan="5">{{ $data->address }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('contactinformation') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('XINGMING') }}</td>
                    <td>{{ $data->first_name }}</td>
                    <td class="tth">{{ ts('PHONENUMBER') }}</td>
                    <td>{{ $data->cell_phone }}</td>
                    <td class="tth">{{ ts('WECHATID') }}</td>
                    <td>{{ $data->wechat_id }}</td>
                </tr>
                {{--<tr>
                    <td colspan="6" class="tst">{{ ts('BEIZHU') }}</td>
                </tr>
                <tr>
                    <td colspan="6" height="64">{{ $data->note }}</td>
                </tr>--}}
                </tbody>
            </table>
            <div class="my-4">
                @if(session('admin.user_type') != 1)
                    <a href="/{{ request()->path() }}/edit" class="btn btn-primary mr-4">{{ ts('edit') }}</a>
                @endif
                <button class="btn btn-warning" onclick="openPWD()" data-target="#userModal">{{ ts('XGMM') }}</button>
                {{--<button class="btn btn-warning ml-4" onclick="resetPWD({{ $data->id }})">{{ ts('CZMM') }}</button>--}}
            </div>
            {{--<h3 class="section_sub_title">{{ ts('LSBGJL') }}</h3>
            <table class="table s3 text-center">
                <thead>
                <tr class="table-secondary">
                    <th>{{ ts('CZY') }}</th>
                    <th>{{ ts('CZe') }}</th>
                    <th>{{ ts('explain') }}</th>
                    <th>{{ ts('CZsj') }}</th>
                </tr>
                @foreach(getUSH($data->id) as $v)
                    <tr>
                        <td>{{ $v->abbr }}</td>
                        <td class="bg-light">{{ ts('urstatus'.$v->status) }}</td>
                        <td class="bg-light">{{ $v->note }}</td>
                        <td>{{ $v->created_at }}</td>
                    </tr>
                @endforeach
                </thead>
            </table>--}}
        </div>

        <form class="modal fade modal-s1" id="userModal">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title font-green">{{ ts('XGMM') }}</h5>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                    </div>
                    <div class="modal-body">
                        <div class="form-item">
                            <div class="form-label" required="">{{ ts('password') }}</div>
                            <div class="form-input">
                                <input type="text" class="form-control" name="pwd">
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-label" required="">{{ ts('zcsr') }}</div>
                            <div class="form-input">
                                <input type="text" class="form-control" name="pwd_r">
                            </div>
                        </div>
                        <div class="py-3 text-center">
                            <button type="button" class="btn btn-primary" onclick="changePWD()">{{ ts('confirm') }}</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>


    </div>


@endsection
@section('script')
    <script>
        function openPWD() {
            $('#userModal input[name="pwd"]').val('')
            $('#userModal input[name="pwd_r"]').val('')
            $('#userModal').modal()
        }
        function changePWD() {
            var url = '/admin/userinfo/change_pwd';
            var p1 = $('#userModal input[name="pwd"]').val();
            var p2 = $('#userModal input[name="pwd_r"]').val();
            p1 = p1.trim()
            if (!p1) {
                alert('密码不能为空！')
                return false;
            }
            if (p1 != p2) {
                alert('两次密码输入不一致！')
                return false;
            }
            mySwal().then(function (d) {
                if (d !== false) {
                    request.post(url, {
                        pwd: p1,
                        pwd_r: p2,
                    }).then(function (d) {
                        mySwal2(d.msg)
                    }).catch(function (d) {
                        console.log(d)
                    })
                }
            })
            /*mySwalV2({c:'input'}).then(function (d) {
                request.post(url, {
                    note: d
                }).then(function (d) {
                    mySwal2(d.msg)
                }).catch(function (d) {
                    console.log(d)
                })
            }).catch(function (d) {
                console.log(d)
            })
            console.log(url)*/
        }
    </script>
@endsection
